#ifndef SROS_DEVICE_RFID_DEVICE_HPP
#define SROS_DEVICE_RFID_DEVICE_HPP

#include "config/rfid_config.hpp"
#include "devices/detail/proto.hpp"
#include "devices/detail/rfid_impl.hpp"
#include "device_impl.hpp"

#include <vector>
#include <mutex>

namespace sros::device
{
    class McuDevice;

    class RfidDevice final : public device_impl<cfg::RfidCfg>
    {
    public:
        using EventCb = std::function<void(const uint8_t &ev_id, const uint32_t &data, const std::string &msg)>;

        RfidDevice(std::shared_ptr<McuDevice> mcu_device);
        ~RfidDevice() override;

        RetBool init() override;

        void run() override;

        void close() override;

        void parse(const device::proto::RspUartMsg &);

        void install_event(EventCb cb);

    protected:
        // 配置加载
        RetBool load_config() override;

    private:
        // 根据配置初始化 RFID 设备
        RetBool init_device_();

    private:
        std::mutex mtx_;
        std::shared_ptr<McuDevice> mcu_;
        std::shared_ptr<detail::rfid_impl> rfid_;

        EventCb event_cb_;
    };
}

#endif